package top.codecrab.eblog.common.properties;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;

/**
 * @author 王刚
 * @since 2022年03月08日 15:21
 */
@Data
@Component
@ConfigurationProperties(prefix = "eblog")
public class EblogProperties {

    private String host;

    private String uploadDir;

    private String adminList;

    private String globalRedisPrefix = "eblog:";

    /** 是否开启全局redis前缀 */
    private Boolean globalRedisPrefixEnable = false;

    private ImServer imServer;

    @Data
    public static class ImServer {
        private String host = "127.0.0.1";
        private int port = 9326;
        private String userDefaultAvatar;

        public List<String> getUserDefaultAvatars() {
            return Arrays.asList(userDefaultAvatar.split(","));
        }
    }

}
